export default {
  state: {
    tagList: [],
    currentPath: "/home",
    parentPath: "",
  },
  getters: {
    getTagList(state) {
      return state.tagList.length
        ? state.tagList
        : JSON.parse(sessionStorage.getItem("routerList"));
    },
    getCurrentPath(state) {
      return state.currentPath;
    },
    getParentPath(state) {
      const path = sessionStorage.getItem("parentPath") || state.parentPath;
      return path;
    },
  },
  mutations: {
    setTagList(state, tagList) {
      state.tagList = tagList;
      sessionStorage.setItem("routerList", JSON.stringify(tagList));
    },
    setCurrentPath(state, path) {
      state.currentPath = path;
      sessionStorage.setItem("currentPath", path);
    },
    setParentPath(state, path) {
      state.parentPath = path;
      sessionStorage.setItem("parentPath", path);
    },
  },
};
